<!DOCTYPE html>
<html lang='en'>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/react.development16.4.0.js"></script>
    <script src="./lib/react-dom.development16.4.0.js"></script>
    <script src="./lib/babel.min.js"></script>
</head>

<body>
    <div id="app">
    </div>
    <script type="text/babel">
   
      class App extends React.Component {
           constructor(props) {
               super(props);
               this.state={
                   age:12
               }
             console.log("获得props和state！！！！")
           }
           
          componentWillMount() {
              console.log("准备加载虚拟DOM");
          }
            
          componentDidMount() {
                console.log("渲染完成！！！");
          }

          componentWillReceiveProps(nextProps) {
              console.log("props传递一个新值！！！");
          }

           componentWillUpdate() {
               console.log("准备重新渲染render");
          }
          componentDidUpdate(prevProps, prevState) {
              console.log("渲染更新结束");
              console.log(prevState.age);
              console.log(prevProps.name);
          }

          render() {  //创建虚拟DOM
             console.log("渲染DOM !!render");
                return (
                    <div>
                      <h1>是的感受到{this.props.name}</h1>
                      <button onClick={()=>{this.setState({age:13})}}>按钮</button>
                      <button onClick={()=>this.props.name='李四'}>更新props</button>
                    </div>
                )
            }
        }
        
        const el = <App name="张三"/>
        ReactDOM.render(
            el,document.getElementById('app')
        );
    </script>
</body>

</html>